home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
PROGRAMM
/
PROGEDIT
/
2285.ZIP
/
MANUALS.EXE
/
PRINTDOC.DOC
< prev
next >
Wrap
Text File
|
1990-08-19
|
11KB
|
207 lines
PRINTDOC UTILITY
****************
This program was written to solve a specific problem, namely the
creation and maintenance of manuals. Essentially the program will format a
text file and break it up into numbered pages, with a user specified number
of lines per page. The concept is very simple, but when you try to write
a program to a acheive this in a logical and intelligent manner you realise
that the procedure needs to be fairly sophisticated in order to work in an
acceptable manner.
Let us suppose for a moment that you have created a document using
a text editor which has created a clean ASCII file (Non-Document Mode) which
consists of 10-15 pages and you have layed out each page in a tidy format
with page breaks occuring in sensible places. At the end of this document you
have created a small index which lists all the major chapter heading along
with the relevant page numbers. Then, sometime later, you need to update the
manual and perhaps add some new paragraphs/pages somewhere near the start of
the document. Immediately you realise that there going to be some problems.
For instance lets take a small example as shown below :-
Fig 1. This example shows how your original document might look before
you have made any modifications.
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
│ │
│ Delete a Line │
│ ------------- │ Bottom of Page 5
│ To delete a line you should press ALT + D │
│ │
│ 5 │
└─────────────────────────────────────────────┘
┌─────────────────────────────────────────────┐
│ │
│ Insert a Line │ Top of Page 6
│ ------------- │
│ To insert a line you should press ALT + I │
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
Fig 2. Then lets suppose that you add some more text to the start of page 5
and see what happens with a lot of word processors
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
│ │
│ will split a line at the cursor position. │<-- The new line(s) added
│ │ here
│ Delete a Line │
│ 5 │<-- has caused the following
└─────────────────────────────────────────────┘ paragraphs to be moved
┌─────────────────────────────────────────────┐ down with the result that
│ ------------- │ this section has now
│ To delete a line you should press ALT + D │ become separated from its
│ │ title.
│ Insert a Line │
│ ------------- │
│ To insert a line you should press ALT + I │
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
Apart from the above difficulty you would also need to check all the
page references in your Index/Contents page.
The PRINTDOC Utility program goes a long way to solving all of these
problems. In the above examples you noticed how text can easily be split
across two pages in a rather ugly manner. To correct this problem you need
to make some changes to your original document. In effect you need to add some
page formatting rules. The following example demonstrates the use of two
simple commands that you can include in your text which when processed by
PRINTDOC will ensure that this type of error does not occur.
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
│ │
Do not allow a ---->│/NOBREAK/ │
page break to occur │ Delete a Line │
from now onwards. │ ------------- │
│ To delete a line you should press ALT + D │
Re-enable page ---->│/BREAK/ │
breaks. │ │
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
When you printout your document using the PRINTDOC Utility program
it will realise that you have marked a block of text and only start printing
it on the current page if all of it is going to fit on the current page,
otherwise a page break is inserted and the entire block of text is placed
on the following page.
Another consequence of you inserting text at the start of a
document is that your Index/Contents Page references need altering. The
PRINTDOC Utility has the ability to automatically create a Contents Page for
you. To place an item in the index you should simple enclose it in the brackets
as shown below :-
┌─────────────────────────────────────────────┐
│ │
│ {[Insert a Line}] │
│ ------------- │
│ To insert a line you should press ALT + I │
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
Note that the order of the {[ and }] brackets remains the same. i.e. they
are not mirror images. This was done because it seemed easier to follow the
same key sequence (Press Shift First) for both sets of brackets.
When the PRINTDOC programs reads a line containing an index entry
is calculates what page that line will be on when the document is printed
and stores it in memory. Then when all of the document has been printed all
of these entries are sorted into alphabetical sequence and printed out.
Any duplicate index entries will result in a index entry being given two
page numbers in the index. Multiple page references for a single index entry
are ignored.
Sometimes you may wish to include an entry in the index which does
not occur in the text. Take for example the following title taken from a
ducument:-
┌─────────────────────────────────────────────┐
│ │
│ {[ALT + D (Delete Line)}] │
│ --------------------- │
│ │
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
As it is shown above you will only get one reference to this
subject in the Contents Page which might look like.
┌─────────────────────────────────────────────┐
│ C O N T E N T S │
│ │
│ ALT + D (Delete Line) 5 │
│ │
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
It would however be desirable to have another reference to this
subject under "Delete Line - ALT 5" in case the person looking in the index
did not know the key combination in question.
To add a reference to the index which does not occur in the text
itself you must use another command as shown below :-
┌─────────────────────────────────────────────┐
│ │
│ ALT + D (Delete Line) │
The COMMENT command --->│/COMMENT/{[Delete Line - ALT F5}] │
will be ignored by │ --------------------- │
PRINTDOC but can be │ │
used to add other \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
index entries.
You should notice that any index items found on a comment line
will be attributed to the same line and page as the last Non-Comment Line.
Other useful command sequences which you can embed in your text
files aree /DEFINE/ and /ENDDEFINE/. To best explain their use it is
necessary to show an example :-
┌─────────────────────────────────────────┐
│/DEFINE/ │
│"U1" EQU "HELLO" │
│"U0" EQU "WORLD" │
│/ENDDEFINE/ │
│ │
│ │
│ │
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
The above example shows how you can define some variables. If at any
point after these definitions have taken place the PRINTDOC finds one of
these variable names in your text it will automatically be replaced by the
appropriate string.
i.e U1 would be replaced with HELLO
This feature is especially useful for defining printer codes. You could
use U1 to turn on underlined print and U0 for turning off underlined print.
You may like to set up BOLDON and BOLDOFF similarly for BOLD printing.
One printer effect has been built into the program and will give you a
shaded background effect. To use this printer effect you should surround
the string as follows :-
/HI/Test String/LO/
This effect has been hard coded and as yet cannot be reconfigured if it
does not work with your printer. One note to remember is that this effect
cannot be used over any IBM line characters (ASCII 176-223). This limitation
may be removed later on.
The ASCII character used to overtype the line and create the shading
effect is 176 ░ but you can change this with a command in your text file. To
change the character you should use the following command in the syntax shown
below :-
/SHADING/▓
There is one important note to remember when changing the shading
pattern. If you change the shading character in a block of text which has
been defined as a /NOBREAK/ area then all the lines defined will be printed
using the last /SHADING/ definition found within that block. Outside a
/NOBREAK/ block the shading command will take effect immediatly.
To run the program you should just type in PRINTDOC and press enter. You will
then be prompted to enter the name of up to 10 input files which will be
used to create you manual. When you have finished entering filenames you should
just press enter at which point you will be asked how many lines you want to
print on each page. You are then given the opportunity to select a range of
page numbers to print. Lastly you can decide where the output from the program
should be sent. You can send output either directly to the printer or redirect
it to a file.